﻿@using QDT.Common
@using QDT.Core.Projects
@model QDT.Common.IPagedList<QDT.Core.Projects.Project>
@{
    Func<ProjectStatus, string> FormatStatus = x =>
    {
        switch (x)
        {
            case ProjectStatus.Full:
                return "<span style='color:red;'>" + ProjectStatus.Full.ToLocalizable() + "</span>";
            default:
                return x.ToLocalizable();
        }
    };
}
@section HeadSection {
    @Html.IncludeCSS("~/Content/Css/calendar.css")
    @Html.IncludeScript("~/Content/JS/calendar.js")
    <script type="text/javascript">

        function show_detail(projectId) {

            var url = '@Url.Action("ShowDetail")' + '?id=' + projectId;

            showAjaxResult(url, "借款详细统计", 600, 400);
        }

    </script>
}
<div class="main_title">
    还款中的贷款</div>
<div class="blank5">
</div>
<div class="button_row">
    @Html.ActionLink("新增", "AddProject", new { }, new { @class = "button" })
@*    <a class="button" href="javascript: del()">删除</a>*@
</div>
<div class="blank5">
</div>
<div class="search_row">
	<form name="search" action="@Url.Action("Repaying")" method="get">	
        编号：<input type="text" class="textbox" name="projectId" value="@Request.Params["projectId"]" size="8"/>
        贷款名称：<input type="text" class="textbox" name="name" value="@Request.Params["name"]"/>
		分类:
        <select name="typeID">
            <option value="-1">所有分类</option>
            @foreach (var type in ViewData["ProjectTypes"] as IList<ProjectType>)
            {
                <option value="@type.ID">@type.Name</option>
            }
        </select>
	    用户名：<input type="text" class="textbox" name="username" value="@Request.Params["username"]" size="8"/>
        日期：<input type="text" class="textbox" id="createTime" name="time" value="@Request.Params["time"]" onfocus=" this.blur(); return showCalendar('createTime', '%Y-%m-%d', false, false, 'btn_CreateTime');" size="8"/>
        <input type="button" class="button" id="btn_CreateTime" value="选择时间" onclick=" return showCalendar('createTime', '%Y-%m-%d', false, false, 'btn_CreateTime'); " />
		<input type="submit" class="button" value="搜索" />
        <a id="export_change_list" href="@Url.Action("RepayingList", "Export", new { time = Request.Params["time"] })" class="button">导出</a>
	</form>
</div>
<div class="grid_box">
    <div class="grid_top">
    </div>
    @Html.Grid(Model).Columns(column =>
{
    column.CheckBox(x => x.ID);
    column.For(x => x.ID).Named("编号").HeaderAttributes(style => "width:50px;");
    column.For(x => x.NextRepayTime).Named("下一次还款时间");
    column.For(x => x.RepayStartTime).Named("开始还款时间");
    column.For(x => Html.ActionLink(x.Name, "EditProject", new { id = x.ID })).Named("贷款名称").SortColumnName("Name");
    column.For(x => Html.F().GetPrjectTypeName(x.TypeID)).Named("贷款类型").SortColumnName("TypeID");
    column.For(x => (x.RepayTimeType == 0 ? (x.RepayTime + "天") : (x.RepayTime + "月"))).Named("期限").SortColumnName("RepayTime");
    column.For(x => Html.F().GetUserName(x.UserID)).Named("借款人").SortColumnName("UserID");
    column.For(x => FormatStatus(x.Status)).Named("投标状态").SortColumnName("InnerStatus").Encode(false);
    column.For(x => x.IsOffline ? "易存宝" : "散标").Named("分组").SortColumnName("IsOffline");
    column.For(x => x.IsEffect ? "有效" : "无效").Named("状态").SortColumnName("IsEffect");
    column.Buttons(btns => btns.Add(x => Html.ActionLink("编辑", "EditProject", new { id = x.ID }))
                               .Add(x => Html.ActionLink("还款", "Refund",new {id=x.ID}))
                               .Add(x => Html.ScriptLink("投标列表", "show_detail({0})", x.ID))
                               );
}).Complex(ViewData)
    <div class="grid_foot">
    </div>
</div>
<div class="blank5">
</div>
@Html.Pager(Model)